mod xlock;

#[macro_use]
extern crate lazy_static;
extern crate global_counter;
extern crate tokio;

use std::thread;
use crate::xlock::{lock, init};
use std::thread::sleep;
use std::time::Duration;


#[tokio::main]
async fn main() {
    init();
    let r = lock(&String::from("B"), 1);
    let r = lock(&String::from("A"), 2);

    let t1 = thread::spawn(move || {
        let r = lock(&String::from("A"), 1);
        sleep(Duration::new(3, 0));
    });

    let t2 = thread::spawn(move || {
        let r = lock(&String::from("B"), 2);
        sleep(Duration::new(3, 0));
    });

    t1.join();
    t2.join();
}

